package com.muyu.danmo.service.impl;

import com.muyu.common.core.domain.Result;
import com.muyu.common.core.utils.DateUtils;
import com.muyu.danmo.domain.DanmoSealCollection;
import com.muyu.danmo.mapper.DanmoSealCollectionMapper;
import com.muyu.danmo.service.IDanmoSealCollectionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 印章图片集Service业务层处理
 *
 * @author yangle
 * @date 2024-11-25
 */
@Service
public class DanmoSealCollectionServiceImpl implements IDanmoSealCollectionService {
    @Autowired
    private DanmoSealCollectionMapper danmoSealCollectionMapper;

    /**
     * 查询印章图片集
     *
     * @param id 印章图片集主键
     * @return 印章图片集
     */
    @Override
    public DanmoSealCollection selectDanmoSealCollectionById(Long id) {
        return danmoSealCollectionMapper.selectDanmoSealCollectionById(id);
    }

    /**
     * 查询印章图片集列表
     *
     * @param danmoSealCollection 印章图片集
     * @return 印章图片集
     */
    @Override
    public List<DanmoSealCollection> selectDanmoSealCollectionList(DanmoSealCollection danmoSealCollection) {
        return danmoSealCollectionMapper.selectDanmoSealCollectionList(danmoSealCollection);
    }

    /**
     * 新增印章图片集
     *
     * @param danmoSealCollection 印章图片集
     * @return 结果
     */
    @Override
    public Result insertDanmoSealCollection(DanmoSealCollection danmoSealCollection) {
        try {
            danmoSealCollection.setCreateTime(DateUtils.getNowDate());
            danmoSealCollectionMapper.insertDanmoSealCollection(danmoSealCollection);
            return Result.success(danmoSealCollection, "添加成功");
        } catch (Exception e) {
            return Result.reportedanerror("添加失败");
        }


    }

    /**
     * 修改印章图片集
     *
     * @param danmoSealCollection 印章图片集
     * @return 结果
     */
    @Override
    public Result updateDanmoSealCollection(DanmoSealCollection danmoSealCollection) {
        try {

            danmoSealCollection.setUpdateTime(DateUtils.getNowDate());
            danmoSealCollectionMapper.updateDanmoSealCollection(danmoSealCollection);
            return Result.success(danmoSealCollection, "修改成功");
        } catch (Exception e) {
            return Result.reportedanerror("修改失败");
        }
    }

    /**
     * 批量删除印章图片集
     *
     * @param ids 需要删除的印章图片集主键
     * @return 结果
     */
    @Override
    public Result deleteDanmoSealCollectionByIds(Long[] ids) {
        try {
            danmoSealCollectionMapper.deleteDanmoSealCollectionByIds(ids);
            return Result.success(ids, "删除成功");
        } catch (Exception e) {
            return Result.reportedanerror("删除拾贝");
        }
    }

    /**
     * 删除印章图片集信息
     *
     * @param id 印章图片集主键
     * @return 结果
     */
    @Override
    public Result deleteDanmoSealCollectionById(Long id) {
        try {
            danmoSealCollectionMapper.deleteDanmoSealCollectionById(id);
            return Result.success(id, "删除成功");
        } catch (Exception e) {
            return Result.reportedanerror("删除失败");
        }
    }
}
